#pragma once
#include <stdio.h>
#include "./unicorn/unicorn.h"
#include <string>
typedef unsigned char BYTE;
#define logger(format, ...) printf(format"\n", __VA_ARGS__)
typedef void(*hook_fun)(uc_engine * uc);

#define DL_ERR(s)
#define DEBUG(s)
#define DL_WARN(s)

#define PAGE_SIZE 4096

#define ElfW(type) Elf32_ ## type
#define ELFW(what) ELF32_ ## what
//#define ElfW(type) Elf64_ ## type
//#define ELFW(what) ELF64_ ## what

#define EM_ARM 40
#define ELF_TARG_MACH		EM_ARM

#define PAGE_MASK (~(PAGE_SIZE - 1))
#define PAGE_START(x)  ((x) & PAGE_MASK)

// Returns the offset of address 'x' in its page.
#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK)

// Returns the address of the next page after address 'x', unless 'x' is
// itself at the start of a page.
#define PAGE_END(x)    PAGE_START((x) + (PAGE_SIZE-1))

#define MAP_PRIVATE 0
#define MAP_FAILED 0
#define MAP_ANONYMOUS 0
#define PROT_NONE 0
#define MAP_FIXED 0
enum {
#if defined(__LP64__)
	RTLD_NOW = 2,
#else
	RTLD_NOW = 0,
#endif
	RTLD_LAZY = 1,

	RTLD_LOCAL = 0,
#if defined(__LP64__)
	RTLD_GLOBAL = 0x00100,
#else
	RTLD_GLOBAL = 2,
#endif
	RTLD_NOLOAD = 4,
};

#define STACK_ADDR  0x00000000
#define STACK_SIZE  0x00100000

#define HOOK_MEMORY_BASE  0x1000000
#define HOOK_MEMORY_SIZE  0x2000000 //0x0200000  // 2 * 1024 * 1024 - 2MB

#define HEAP_BASE  0x2000000
#define HEAP_SIZE  0x0200000  // 2 * 1024 * 1024 - 2MB

#define BASE_ADDR  0xCBBCB000

#define WRITE_FSTAT_TIMES  1